#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point&)" << endl;
    }


    //this指针原本是Point * const this
    //const成员函数的this指针变成了const Point * const this
    void print() const{
        /* _ix = 100; */
        cout << "const版本的print" << endl;
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    //如果一个成员函数中不打算修改对象的内容
    //那么可以将这个成员函数设为const成员函数
    /* void print(){ */
    /*     /1* _ix = 100; *1/ */
    /*     cout << "非const版本的print" << endl; */
    /*     cout << "(" << _ix */
    /*         << "," << _iy */
    /*         << ")" << endl; */
    /* } */
private:
    int _ix;
    int _iy;
};

void test0(){
    const int a = 1;
    /* a = 10; */
    cout << a << endl;

    Point pt(10,8);
    /* pt._ix = 1000; */
    pt.print();

    const Point pt2(3,5);
    /* pt2._ix = 1000; */
    pt2.print();

}

int main(void){
    test0();
    return 0;
}
